<?php
set_time_limit(0);
require('phpQuery/phpQuery.php');
$link = mysql_connect('localhost', 'root', '');
mysql_select_db('test', $link);
mysql_query('SET NAMES UTF8');

$sql = "select * from info where content = ''";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
	$result2 = phpQuery::newDocumentFile($row['url']);
	$title = trim($result2->find('.h1')->text());
	$content = $result2->find('founder-content')->text();
	preg_match('/证券代码：(\d{6})/', $content, $match2);
	preg_match("/证券简称：(.*?)公告编号/", $content, $match3);
	//$code = preg_match('/证券代码：(\d{6})/', $content, $match4);
	//print_r($match2);
	//print_r($match3);
	$code = !empty($match2[1]) ? trim($match2[1]) : '';
	$name = !empty($match3[1]) ? trim($match3[1]) : '';
	$sql = "UPDATE info SET title = '{$title}', code = '{$code}', name = '{$name}', content = '{$content}' where url = '{$row['url']}'";
	mysql_query($sql);
}

